#！/usr/bin/env python
#!coding=utf-8

import os 
import sys
import Node

def swap(data, i, j):
    tmp = data[i]
    data[i] = data[j]
    data[j] = tmp

def list_op():
    line = "i am from wuhan, are you ok"
    blank = ' '
    data = line.replace(',', blank).split(blank)
    data = list(filter(lambda x:len(x) > 0, data))
    print(data)
    # reverse list
    i = 0
    j = len(data) - 1
    while (i < j):
        swap(data, i, j)
        i = i + 1
        j = j - 1

    print(data)

def link_op():
    print("link is")
    data = [1, 2, 3, 4, 5]
    link1 = Node.LinkList()
    link1.init_list(data)
    #print(link1.head.val)
    link1.traverse()
    link1.append_node(10)
    link1.traverse()
    print("after reverse.....")
    link1.reverse()
    link1.traverse()

def run():
    print("hello!")
    name = "hello world!" # string is a kind of special list
    print(name[0:-1])
    print(name[0:1])
    print(name[5:-1])
    print("maybe wrong")
    print(name*2)
if __name__ == "__main__":
    #run()
    #list_op()
    link_op()